package com.mimiwang.school.controller;

import com.mimiwang.common.utils.ResponseUtil;
import com.mimiwang.school.VO.PageConfig;
import com.mimiwang.school.service.ISchoolAreaService;
import com.mimiwang.school.service.ISchoolCampusService;
import com.mimiwang.school.service.ISchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @AUTHOR:游李滨
 * @DATE:2023/4/17 23:30
 */

@RestController
@RequestMapping("/school")
public class SchoolController {

    @Autowired
    ISchoolService schoolService;

    @Autowired
    ISchoolCampusService schoolCampusService;

    @Autowired
    ISchoolAreaService schoolAreaService;
    /**
     * 根据省份id和城市id查询所有学校
     *
     *
     * */
    @GetMapping("/pos")
    String getAllSchoolByProvinceAndCity(long pro, long city,int page) {
        PageConfig pageConfig = new PageConfig(page, 10);
        return ResponseUtil.successJSONData(schoolService.selectSchoolByProvinceIdAndCityId(pro, city, pageConfig));
    }

    /**
     * 根据学校id查询学校的详情信息
     * */
    @GetMapping("/detail")
    String getDetailSchool(long schoolId) {

        return ResponseUtil.successJSONData(schoolService.selectSchoolAndCampusAndAreaBySchoolId(schoolId));
    }
    @GetMapping("/simple")
    String getSimpleSchool(long schoolId) {

        return ResponseUtil.successJSONData(schoolService.selectSchoolAndCampusBySchoolId(schoolId));
    }
    @GetMapping("/like")
    String getSchoolByLike(String like){

        return ResponseUtil.successJSONData(schoolService.selectSchoolListByLike(like));

    }


}
